<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>

<form id="form_evento"
	action="<?php echo url_for('evento/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id_evento='.$form->getObject()->getIdEvento() : '')) ?>"
	method="post"
	<?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
	<?php if (!$form->getObject()->isNew()): ?> <input type="hidden"
	name="sf_method" value="put" /> <input type="hidden" name="id_evento"
	value="<?php echo $form->getObject()->getIdEvento() ?>" /> <?php endif; ?>
	<?php echo $form->renderHiddenFields() ?>

<div class="tabs">
    <ul>
        <li><a href="#tab_dados">Dados</a></li>
        <?php if (!$form->getObject()->isNew()): ?>
            <li><a href="<?php echo url_for('midia/arquivos?ref_name=id_evento&ref_value='.$form->getObject()->getIdEvento().'&hasmany=true'); ?>">Arquivo(s)</a></li>
        <?php else: ?>
            <li><a href="#tab_midia">Imagens(s)</a></li>
        <?php endif; ?>
    </ul>
    
    <div id="tab_dados">
		<table class="form">
			<tbody>
				<tr>
					<th colspan="2" class="title">Dados evento</th>
				</tr>
				<?php echo $form->renderGlobalErrors() ?>
				<tr>
					<th><?php echo $form['nm_evento']->renderLabel() ?></th>
					<td><?php echo $form['nm_evento'] ?> <?php echo form_error('evento[nm_evento]'); ?></td>
				</tr>
				<tr>
					<th><?php echo $form['ds_resumo']->renderLabel() ?></th>
					<td><?php echo $form['ds_resumo'] ?> <?php echo form_error('evento[ds_resumo]'); ?></td>
				</tr>
				<tr>
					<th><?php echo $form['ds_evento']->renderLabel() ?></th>
					<td><?php echo $form['ds_evento'] ?> <?php echo form_error('evento[ds_evento]'); ?></td>
				</tr>
				<tr>
					<th><?php echo $form['st_evento']->renderLabel() ?></th>
					<td><?php echo $form['st_evento'] ?> <?php echo form_error('evento[st_evento]'); ?></td>
				</tr>
				<tr>
					<th><?php echo $form['dt_evento']->renderLabel() ?></th>
					<td><?php echo $form['dt_evento'] ?> <?php echo form_error('evento[dt_evento]'); ?></td>
				</tr>
			</tbody>
		</table>
	</div>
	
	<?php if ($form->getObject()->isNew()): ?>
    <div id="tab_midia">
        <?php include_component('midia', 'new', array('form' => $form, 'hasmany' => true, 'name' => 'evento')); ?>
    </div>
    <?php endif; ?>
</div>
</form>

<?php
	comandos_form(
		link_to(
			':: Listar ::',
			'evento/list',
			array('class' => 'botao')
		),
		button_to_function(
			':: Salvar ::',
			"$('#form_evento').submit()",
			array('class' => 'botao')
		)
	);
?>

<script type="text/javascript">
$(function()
{
	System.setdata.tab();
	System.formdata.calendar();
});
</script>